<template>
<div class="recycle-evaluation views-container">
    <div class="wlm-table">
        <div class="wlm-table-header">
            <el-form :model="tableFormatData.userTable.files" size="small" label-width="82px" class="retail-form" label-position="right">
                <el-form-item label="" class="filter">
                    <el-form-item label="买家：">
                        <el-input v-model="tableFormatData.userTable.files.nickName" placeholder="请输入买家姓名" style="width:200px;"></el-input>
                    </el-form-item>
                    <el-form-item label="商品名称：">
                        <el-input v-model="tableFormatData.userTable.files.goods_name" placeholder="请输入商品名称" style="width:200px;"></el-input>
                    </el-form-item>
                </el-form-item>
                <el-form-item label="" class="filter">
                    <el-form-item label="评论等级：">
                        <el-select v-model="tableFormatData.userTable.files.score" placeholder="请选择" style="width:200px;">
                            <el-option :label="'好评'" :value="3">
                            </el-option>
                            <el-option :label="'中评'" :value="2">
                            </el-option>
                            <el-option :label="'差评'" :value="1">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="评论来源：">
                        <el-select v-model="tableFormatData.userTable.files.source" placeholder="请选择" style="width:200px;">
                            <el-option :label="'微信小程序'" :value="'2'">
                            </el-option>
                            <el-option :label="'H5'" :value="'3'">
                            </el-option>
                            <el-option :label="'微信公众号'" :value="'4'">
                            </el-option>
                        </el-select>
                    </el-form-item>
                </el-form-item>
                <el-form-item label="" class="filter-btns">
                    <el-button type="primary" @click="filesSerch">筛选</el-button>
                    <el-button type="text" @click="filesEmpty">清空筛选条件</el-button>
                </el-form-item>
            </el-form>
        </div>

        <div class="wlm-table-content">
            <el-tabs v-model="tableFormatData.userTable.files.status" type="card" @tab-click="filesSerch">
                <!-- @tab-click="filesSerch" -->
                <el-tab-pane label="全部评论" name="all"></el-tab-pane>
                <el-tab-pane label="待回复" name="1"></el-tab-pane>
                <el-tab-pane label="已回复" name="2"></el-tab-pane>
            </el-tabs>
            <el-table :ref="tableFormatData.userTable.key" :data="tableFormatData.userTable.tableData" @selection-change="handleSelectionChange" style="width: 100%">
                <el-table-column type="selection" width="55">
                </el-table-column>
                <el-table-column prop="date" label="买家" >
                    <template slot-scope="scope">
                        <p>{{scope.row.nickName}}</p>
                        <p>ID:{{scope.row.user_id}}</p>
                    </template>
                </el-table-column>
                <el-table-column prop="date" label="商品名称" >
                    <template slot-scope="scope">
                        <span>{{scope.row.goods_name}}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="date" label="状态" >
                    <template slot-scope="scope">
                        <span>{{scope.row.status ? '显示' :'隐藏'}}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="date" label="评论等级" >
                    <template slot-scope="scope">
                        <el-rate disabled v-model="scope.row.score" :colors="['#99A9BF', '#F7BA2A', '#FF9900']">
                        </el-rate>
                    </template>
                </el-table-column>
                <el-table-column prop="date" label="评论来源" >
                    <template slot-scope="scope">
                        <span>{{sourceType[`${scope.row.source || '-'}`]}}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="date" label="评论时间" >
                    <template slot-scope="scope">
                        <span>{{scope.row.create_time}}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="address" label="操作" >
                    <template slot-scope="scope">
                        <div class="operation-group">
                            <el-button class="wlm-text" type="text" @click="changeTableItem({ids:[scope.row.category_id],type:'comment'},tableFormatData.userTable.change.restore)">恢复</el-button>
                            <div class="btn-line"></div>
                            <el-button class="wlm-text" type="text" @click="delTableItem(scope.row.refund_reason_id)">删除</el-button>
                        </div>
                    </template>
                </el-table-column>
            </el-table>
            <div class="pagination-content flex-row flex-justify-b flex-align-c">
                <el-row class="pagination-btns">
                    <el-checkbox class="check-all" true-label="1" false-label="0" v-model="tableFormatData.userTable.files.checkall" @change="toggleSelection">全部</el-checkbox>
                    <el-button class="right-8" type="primary" :disabled="isGroup" size="mini" @click="changeTableItem({isGroup:true,type:'comment'},tableFormatData.userTable.change.restore)">批量恢复</el-button>
                    <el-button class="right-8" :disabled="isGroup" size="mini" @click="delTableList">删除</el-button>
                </el-row>
                <el-pagination :disabled="!hasTableData" @size-change="listPageChange" @current-change="listPageChange" :current-page.sync="tableFormatData.userTable.pagination.page" :page-sizes="tableFormatData.userTable.pagination.pagesizes" :page-size.sync="tableFormatData.userTable.pagination.list_rows" layout="total, sizes, prev, pager, next, jumper" :total="hasTableData?tableFormatData.userTable.pagination.total : 0">
                </el-pagination>
            </div>
        </div>
    </div>
</div>
</template>

<script>
import {
  getDelCommentList,
  recoveryDeletedInfo,
  deleteThoroughlyInfo
} from '@/api/recycle'
import mixins from '@/mixins/mixins'
export default {
  mixins: [mixins.getters('Table')],
  name: 'RecycleEvaluation',
  components: {

  },
  data() {
    return {
      replyMsg: {
        isGroup: true,
        content: ''
      },
      sourceType: {
        '1': '导入',
        '2': '微信小程序',
        '3': 'H5',
        '4': '公众号',
        '5': '安卓',
        '6': '苹果',
        '7': '支付宝小程序',
        '8': '百度小程序',
        '9': '头条小程序',
        '-': '-'
      },
      tableFormatData: {
        current: 'userTable',
        userTable: {
          key: 'userTable',
          api: {
            getList: getDelCommentList,
            delList: deleteThoroughlyInfo
          },
          tableData: [],
          files: {
            nickName: '',
            goods_name: '',
            score: '',
            source: '',
            status: 'all',
            ids: [],
            redirect: 'comment_id',
            checkall: '0',
            Recycle: '0',
            type: 'comment'
          },
          change: {
            restore: {
              name: '恢复',
              key: 'restore',
              api: recoveryDeletedInfo
            }
          },
          pagination: {
            page: 1,
            list_rows: 10,
            pagesizes: [10, 20, 50],
            total: 0
          }
        }
      }
    }
  },
  methods: {
    updateMsg(event) {
      const { target: { value = '' } } = event
      this.replyMsg.content = value
    }
  }
}
</script>

<style lang="scss" scoped>
.recycle-evaluation {
    .logo {
        height: 32px;
        width: 32px;
        border-radius: 32px;
        vertical-align: middle;
    }
}
</style>
